<!DOCTYPE html>
<html lang="en">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="css/style.css" rel="stylesheet">
</head>

<body>
    <script>
        let arr = [1, 2, 2, 3]
        // 奇偶数中的众数
        let obj1 = {}
        let obj2 = {}
        for (let i = 0; i < arr.length; i++) {
            if (i % 2 == 1) {
                if (obj1[arr[i]]) {
                    obj1[arr[i]]++
                } else {
                    obj1[arr[i]] = 1
                }
            } else {
                if (obj2[arr[i]]) {
                    obj2[arr[i]]++
                } else {
                    obj2[arr[i]] = 1
                }
            }
        }
        let max = 0
        let arrObj1 = Object.keys(obj1)
        let arrObj2 = Object.keys(obj2)
        for (let i = 0; i < arrObj1.length; i++) {
            for (let j = 0; i < arrObj2.length; j++) {
                if (arrObj1[i] != arrObj2[j]) {
                    max = Math.max(obj1[arrObj1[i]] + obj2[arrObj2[j]], max)
                }
            }
        }
        let res = 0
        res = arr.length - max
        console.log(res)
    </script>
</body>

</html>